<?php

vendor('phpcaptcha'.DS.'php-captcha.inc');

class CaptchaComponent extends Object
{
    var $controller;
    var $oVisualCaptcha;

    function startup(&$controller)
    {
        $this->controller = &$controller;
    }

    function image()
    {

        $imagesPath = Application::vendorsRootPath().DS.'phpcaptcha'.DS.'fonts'.DS;

        $aFonts = array(
            $imagesPath.'VeraBd.ttf',
            $imagesPath.'VeraIt.ttf',
            $imagesPath.'Vera.ttf'
        );

        $this->oVisualCaptcha = new PhpCaptcha($aFonts, 200, 60);
        $this->oVisualCaptcha->UseColour(false);
        $this->oVisualCaptcha->SetCharSet('0-9');
        $this->oVisualCaptcha->SetBackgroundImages(Application::vendorsRootPath().DS.'phpcaptcha'.DS.'captcha-bg.jpg');
        //$this->oVisualCaptcha->SetOwnerText('Source: '.FULL_BASE_URL);
        $this->oVisualCaptcha->SetNumChars(6);
        $this->oVisualCaptcha->Create();
    }

    /*function audio()
    {
        $oAudioCaptcha = new AudioPhpCaptcha('/usr/bin/flite', '/tmp/');
        $oAudioCaptcha->Create();
    }*/

    function check($userCode, $caseInsensitive = true)
    {
        return $this->oVisualCaptcha->check($userCode, $caseInsensitive);
    }

}

?>
